package com.yyz.config;

import com.yyz.interceptor.LoginCheckInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.Collections;

/**
 *
 * @author yyz
 * @create 2023-07-18 21:25
 */
@Slf4j
//@Configuration
public class WebConfig implements WebMvcConfigurer {
//    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    /**
     * 定义不需要处理的请求路径
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //定义不需要处理的请求路径
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"/employee/login", "/employee/logout", "/backend/**", "/front/**");

        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**")
                .excludePathPatterns(list);
    }

}
